﻿using System;
using Core.Domain.Bases;
using Core.Domain.Entities;
using FluentNHibernate;
using FluentNHibernate.AutoMap;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using FluentNHibernate.Testing;
using MbUnit.Framework;
using NHibernate;

namespace Tests.Domain.Mapping
{/*
  public class FixtureBase
  {
    protected SessionSource SessionSource { get; set; }
    protected ISession Session { get; private set; }

    [SetUp]
    public void SetupContext()
    {
      var cfg = Fluently.Configure()
            .Database(SQLiteConfiguration.Standard.InMemory);
      SessionSource = new SessionSource(cfg.BuildConfiguration()
                                              .Properties, new TestModel());
      Session = SessionSource.CreateSession();
      SessionSource.BuildSchema(Session);

      cfg = Fluently
      .Configure()
      .Database(SQLiteConfiguration.Standard.InMemory);
      
      SessionSource = new SessionSource(cfg.BuildConfiguration().Properties, new PersistenceModel());
      Session = SessionSource.CreateSession();
      SessionSource.BuildSchema(Session);
      
      .Mappings(m => m.AutoMappings.Add(AutoPersistenceModel.MapEntitiesFromAssemblyOf<EntityBase>().Where(t => t.IsInstanceOfType(typeof(EntityBase)))))
      .BuildSessionFactory();

    }

    [TearDown]
    public void TearDownContext()
    {
      Session.Close();
      Session.Dispose();
    }
  }

  public class TestModel : PersistenceModel
  {
    public TestModel()
    {
      this.addMappingsFromThisAssembly().
       addMappingsFromAssembly(typeof (CustomerMapping).Assembly);
    }
  }

  [TestFixture]  
  public class PersonMapping_Fixture : FixtureBase  
  {  
      [Test]  
      public void can_correctly_map_customer()  
      {  
          new PersistenceSpecification<Person>(Session)  
              .CheckProperty(c => c.Id, 1001)  
              .CheckProperty(c => c.FirstName, "John")  
              .CheckProperty(c => c.LastName, "Doe")  
              .CheckProperty(c => c.OtherFirstNames, "John")  
              .CheckProperty(c => c.OtherLastNames, "Doe")  
              .CheckProperty(c => c.BahaiId, "78279")  
              .CheckProperty(c => c.BirthDate, DateTime.Today)  
              .CheckProperty(c => c.AdminRightsRemoved, false)  
              .VerifyTheMappings();  
      }  
  }  
  */
}